package com.share.two.bio2;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadPool {
	
	private ExecutorService executorService;
	
	public ThreadPool(int maxPoolSize, int queueSize) {
		this.executorService = new ThreadPoolExecutor(
				Runtime.getRuntime().availableProcessors(), 
				maxPoolSize, 
				120, 
				TimeUnit.SECONDS, 
				new ArrayBlockingQueue<Runnable>(queueSize));
	}
	
	public void  execute(Runnable runnable) {
		this.executorService.execute(runnable);
	}
	
}
